package com.briup.jz.web.controller;

import com.briup.jz.bean.AccountCustomer;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.AccountEmployee;
import com.briup.jz.service.AccountEmployeeService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

@Api(description = "账户员工分类相关接口")
@Validated
@RestController
@RequestMapping("/accountEmployee")
public class AccountEmployeeController {

	@Autowired
	private AccountEmployeeService accountEmployeeService;

	// 根据id查询员工银行账户充值提现信息

	@ApiOperation(value = "查询账户消费信息(多条件查询.)")
	@GetMapping("query")
	@ApiImplicitParams({ @ApiImplicitParam(name = "type", value = "交易类型（提现、充值）", paramType = "query"),
			@ApiImplicitParam(name = "status", value = "状态[正常]", paramType = "query"),
			@ApiImplicitParam(name = "userId", value = "用户编号", paramType = "query") })
	public Message query(String type,String status,Long userId) {
		List<AccountEmployee> list = accountEmployeeService.query(type,status,userId);
		return MessageUtil.success(list);
	}

	// 保存或者更新
	@ApiOperation(value = "保存或更新资员工银行卡消费信息")
	@PostMapping("/saveOrUpdate")
	@ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "编号[更新的时候需要填写]", paramType = "form"),
			@ApiImplicitParam(name = "transferMoney", value = "交易金额", required = true, paramType = "form"),
			@ApiImplicitParam(name = "type", value = "交易类型[提现、充值]", required = true, paramType = "form"),
			@ApiImplicitParam(name = "description", value = "备注", paramType = "form"),
			@ApiImplicitParam(name = "status", value = "状态正常", required = true, paramType = "form"),
			@ApiImplicitParam(name = "userId", value = "用户编号", required = true, paramType = "form") })
	public Message saveOrUpdate(Long id, Double transferMoney, String type,String description, String status, Long userId) {
		AccountEmployee accountEmployee = new AccountEmployee();
		accountEmployee.setId(id);
		accountEmployee.setTransferMoney(transferMoney);
		accountEmployee.setType(type);
		accountEmployee.setDescription(description);
		accountEmployee.setStatus(status);
		accountEmployee.setUserId(userId);
		accountEmployeeService.saveOrUpdate(accountEmployee);
		return MessageUtil.success("操作成功");
	}

	// 删除一个id信息
	@ApiOperation(value = "删除员工银行账户消费信息")
	@PostMapping("/deleteById")
	public Message deleteById(long id) {
		accountEmployeeService.deleteById(id);
		return MessageUtil.success("删除成功");
	}

}
